package com.ztf666.articlereview.controller;


import com.ztf666.articlereview.dto.R;
import com.ztf666.articlereview.entity.Article;
import com.ztf666.articlereview.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author z
 * @date 2022/2/21 上午10:47
 */
@RequestMapping("/article")
@RestController
public class ArticleController {
    private ArticleService articleService;

    @Autowired
    public void setArticleService(ArticleService articleService) {
        this.articleService = articleService;
    }

    @PostMapping("/addArticle")
    public R addArticle(Integer UserId, String name, String desc) {
        articleService.addArticle(UserId, name, desc);
        return R.setOK();
    }

    @GetMapping("/getArticle")
    public R getArticle(int aid) {
        List<Article> articleList = articleService.findArticle(aid);
        return R.setOK(articleList);
    }

}
